#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QDateTime>
#include <QSettings>
#include <QVector>
#include <QTimer>
#include <widgets/quiwidget.h>
#include <digitalfiltering.h>

QT_BEGIN_NAMESPACE
namespace Ui
{
    class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void timerSlot();
    void plotFreqData();
    void plotTimeData();
    void updateSignalFearure();
    void clearSignalFearure();
    void loadSimuData();
    bool loadCsvFile(QString file, int type);
    void updateTimePlotZoom();
    void updateFreqPlotZoom();

    void timeMoveEvent(QMouseEvent *event);
    void freqMoveEvent(QMouseEvent *event);

    void on_chooseCsvDirBtn_clicked();

    void on_timePlotSavePngBtn_clicked();

    void on_timePlotZoomHBtn_toggled(bool checked);

    void on_stopSampleBtn_clicked();

    void on_timePlotZoomVBtn_toggled(bool checked);

    void on_freqPlotZoomHBtn_toggled(bool checked);

    void on_freqPlotZoomVBtn_toggled(bool checked);

    void on_startSampleBtn_clicked(bool checked);

    void on_pauseSampleBtn_clicked();

    void on_restartSampleBtn_clicked();

    void on_timePlotClearBtn_clicked();

    void on_freqPlotClearBtn_clicked();

    void on_freqPlotScaleBtn_clicked();

    void on_timePlotScaleBtn_clicked();

    void on_saveTimeDataBtn_clicked();

    void on_saveFreqDataBtn_clicked();

    void on_loadTimeDataBtn_clicked();

    void on_loadFreqDataBtn_clicked();

    void on_freqPlotSavePngBtn_clicked();

signals:

private:
    Ui::MainWindow *ui;
    QUIWidget quiLog;
    QTimer *mTimer;
    QSettings mSettings;
    //分别存取两种图的x,y值作全局变量
    QVector<double> dataTimeX;
    QVector<double> dataTimeY1;
    QVector<double> dataTimeY2;
    QVector<double> dataFreqX;
    QVector<double> dataFreqY1;
    QVector<double> dataFreqY2;

    //存取读入的仿真数据
    QVector<QVector<double>> simuData;

    int pCount;     //点数循环计数
    int timeCount; //秒数循环计数
};
#endif // MAINWINDOW_H
